/**
 * 物联卡综合信息-节电参数变更页面
 */

layui.use(['layer', 'form', 'admin'], function () {
    var $ = layui.jquery;
    var form = layui.form;
    var admin = layui.admin;
    var layer = layui.layer;

    // 表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var apnName = $("#apnName").val();
        var precisionType = $("#precisionType").val();
        var precisionVal = $("#precisionVal").val();
        if(apnName === "CMNBIOT"||apnName === "CMNBIOT2" ||apnName === "CMNBIOT6"){
            if(precisionType === "" || precisionVal === "") {
                Feng.error('定时器精度和对应精度值不能为空');
                return;
            }
        }else{
            precisionType = "";
            precisionVal = "";
        }

        $.ajax({
            dataType : "json",
            url : Feng.ctxPath + "/general/changeParamNode",
            type : "post",
            data : $("#cardForm").serialize(),
            success : function(data) {
                if(data.success){
                    layer.open({
                        type: 0,
                        title: '节电参数变更办理结果',
                        area: ['350px', '250px'],
                        content: '<label>任务流水号:</label>' + data.data.jobId,
                        skin: 'layui-layer-molv',
                        yes: function (index, layero) {
                            admin.closeThisDialog();
                        }
                    });
                }
            },
            error : function (data){
                layer.open({
                    content: "节电参数变更失败！" + data.responseJSON.message,
                    skin: 'layui-layer-molv',
                    yes: function (index, layero) {
                        layer.close(index);
                    }
                });
            }
        });
        return false;
    });

});